﻿cmake_minimum_required(VERSION 3.10)
add_definitions(-DUNICODE -D_UNICODE)

project(cmakedemo)
 
set(CMAKE_CXX_STANDARD 14)
 
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})

message("cmakedemo:>>>>>>")
message("CMAKE_LIBRARY_OUTPUT_DIRECTORY = ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
message("CMAKE_RUNTIME_OUTPUT_DIRECTORY  = ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
#message("cmakedemo_SOURCE_DIR  = ${cmakedemo_SOURCE_DIR}")
#message("cmakedemo_BINARY_DIR  = ${cmakedemo_BINARY_DIR}")

#add_subdirectory(acclib)
add_subdirectory(acclib lib)# 添加一个模块，并且将编译好库文件放置在 build/lib 目录

add_executable(cmakedemo main.cpp)      #生成一个可执行的文件
target_link_libraries(cmakedemo acclib) # 链接 acclib

message("RUNTIME_OUTPUT_DIRECTORY = ${RUNTIME_OUTPUT_DIRECTORY}")



# copy the dll to the binary folder
#add_custom_command(TARGET cmakedemo POST_BUILD         # Adds a post-build event to cmakedemo
#    COMMAND ${CMAKE_COMMAND} -E copy_if_different      # which executes "cmake - E copy_if_different..."
#        "${CMAKE_CURRENT_BINARY_DIR}/lib/acclib.dll"   # <--this is in-file
#        "${CMAKE_CURRENT_BINARY_DIR}"                  # <--this is out-file path
#    )

#add_custom_command(TARGET cmakedemo POST_BUILD
#    COMMAND ${CMAKE_COMMAND} -E copy_directory
#        "${CMAKE_CURRENT_BINARY_DIR}/lib"
#        "${CMAKE_CURRENT_BINARY_DIR}")

